GBML manual / Core

profile_phases

How many phases a frame is split into - the jobs the game does every frame, like moving things or drawing sprites. 0 when the profiler is off.

Works differently on Game Boy - The Game Boy has no frame profiler: profile_enabled says false and every profile number reads 0.

Works differently on Game Boy Color - The Game Boy Color has no frame profiler: profile_enabled says false and every profile number reads 0.

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

profile_phases() -> int

Returns

int

Description

A frame is not one job. It is many small ones that the game does in a fixed order, 60 times a second: run every Step event, move everything, find collisions, draw every sprite, and more. The profiler calls each of those jobs a phase, and times them one by one.

This tells you how many phases there are, which is 24 with the profiler on and 0 with it off. They are numbered from 1 up to that number, in the order the frame runs them. Number 0 is not a phase, it is PROFILE_TOTAL: the whole frame. A loop from 1 to profile_phases() visits every phase exactly once, so an overlay never has to list the names itself. The full list is in The frame profiler.

Example

for (var i = 1; i <= profile_phases(); i++) {
    draw_text(4, 4 + i * 6, profile_name(i));
}

Draws the name of every phase on its own line. With the profiler off, profile_phases() is 0, so the loop never runs and nothing is drawn.

On the GBA

Phases are numbered from 1 up to this number, in the order the frame runs them. Number 0 is PROFILE_TOTAL, the whole frame. A loop from 1 to profile_phases() visits every phase once, so an overlay does not need its own list of names.

See also: profile_namePROFILE_TOTAL